home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / libscsi1.zoo / LibScsi-0.01 / scsi_io.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-14  |  5.3 KB  |  117 lines

  1. /*
  2.  * <sys/scsi_io.h> - Steve Woodford, August 1993
  3.  *
  4.  * Device independent Scsi IO interface.
  5.  */
  6.  
  7. #ifndef __sys_scsi_io_h
  8. #define __sys_scsi_io_h
  9.  
  10. #define SCSI_TAPE_ID        64      /* Magic number: == system's tapedrive */
  11.  
  12.  
  13. /*
  14.  * Pass a pointer to a structure of this type to the scsi_ioctl(fd, SCIO_GET)
  15.  * function to get useful information about the associated SCSI device.
  16.  */
  17. typedef struct {
  18.     u_char      sc_id;              /* Scsi ID of Device */
  19.     u_char      sc_lun;             /* Logical Unit number of device */
  20.     u_short     sc_type;            /* Type of Scsi Device */
  21. #define SCT_FIXED_DISK      0
  22. #define SCT_TAPE_DRIVE      1
  23. #define SCT_FLOPPY          2
  24. #define SCT_CD_ROM          3
  25.     u_char      sc_flags;           /* Flags providing mode info */
  26. #define SCF_IS_REMOVABLE    0x01
  27. #define SCF_IS_WRITABLE     0x02
  28.     u_char      sc_sense_key;       /* Contains Sense code after error */
  29.     u_long      sc_sense_blk;       /* Block # of error (if applicable) */
  30.     u_long      sc_blocks;          /* Number of blocks on device */
  31.     u_short     sc_block_sz;        /* Size, in bytes of a block */
  32.     char        sc_vendor[8];       /* Vendor ID */
  33.     char        sc_product[16];     /* Product ID */
  34.     char        sc_revision[4];     /* Revision level */
  35. } Sc_Desc;
  36.  
  37. /*
  38.  * Operations possible using 'scsi_ioctl()'
  39.  */
  40. #define SCIO_REZERO     0           /* Rezero unit                      */
  41. #define SCIO_REWIND     0           /* Rewind (Same as Rezero)          */
  42. #define SCIO_OFFLIN     1           /* Rewind and take Offline          */
  43. #define SCIO_WEOF       2           /* Write a filemark                 */
  44. #define SCIO_RETEN      3           /* Retension tape                   */
  45. #define SCIO_ERASE      4           /* Erase tape                       */
  46. #define SCIO_EOD        5           /* Space to end of recorded data    */
  47. #define SCIO_FSF        6           /* Forward-skip filemark            */
  48. #define SCIO_BSF        7           /* Backward-skip filemark           */
  49. #define SCIO_FSR        8           /* Forward-skip record (block)      */
  50. #define SCIO_BSR        9           /* Backward-skip record (block)     */
  51. #define SCIO_GET        10          /* Get sense data & other info.     */
  52.  
  53. #ifndef SK_NO_SENSE
  54. /*
  55.  * Scsi Sense key values returned in scsi_stat structure
  56.  */
  57. #define SK_NO_SENSE             0x00
  58. #define SK_RECOVERABLE_ERROR    0x01    /* Recoverable error occurred */
  59. #define SK_NOT_READY            0x02    /* Drive Not Ready error */
  60. #define SK_MEDIA_ERROR          0x03    /* Medium Error */
  61. #define SK_HARDWARE_ERROR       0x04    /* Hardware error */
  62. #define SK_ILLEGAL_REQUEST      0x05    /* Illegal Request error */
  63. #define SK_UNIT_ATTENTION       0x06    /* Unit Attention Error */
  64. #define SK_DATA_PROTECTED       0x07    /* Usually Write Protect error */
  65. #define SK_BLANK_CHECK          0x08    /* Blank check error */
  66. #define SK_VENDOR_UNIQUE        0x09    /* Vendor Unique error */
  67. #define SK_COPY_ABORTED         0x0a    /* Copy aborted error */
  68. #define SK_ABORTED_COMMAND      0x0b    /* Aborted Command error */
  69. #define SK_EQUAL                0x0c    /* Equal error */
  70. #define SK_VOLUME_OVERFLOW      0x0d    /* Volume Overflow error */
  71. #define SK_MISCOMPARE           0x0e    /* Miscompare error */
  72. #define SK_RESERVED             0x0f
  73. /* The following sense keys are generated by the Scsi_Io drivers */
  74. #define SK_TIMEOUT              0x10    /* Scsi Bus Timeout */
  75. #define SK_EOF                  0x11    /* Filemark */
  76. #define SK_EOT                  0x12    /* End of tape */
  77. #define SK_BOT                  0x13    /* Beginning of tape */
  78. #define SK_MEDIA                0x14    /* Wrong media */
  79. #define SK_BUSY                 0x15    /* Device busy */
  80.  
  81. /*
  82.  * Text representing the major 'sense key' errors
  83.  */
  84. #define SENSE_KEY_INFO  {                               \
  85.     "No Sense Available",           /* 0x00 */          \
  86.     "Soft Error",                   /* 0x01 */          \
  87.     "Unit Not Ready",               /* 0x02 */          \
  88.     "Media Error",                  /* 0x03 */          \
  89.     "Hardware Error",               /* 0x04 */          \
  90.     "Illegal Request",              /* 0x05 */          \
  91.     "Unit Attention",               /* 0x06 */          \
  92.     "Write Protected",              /* 0x07 */          \
  93.     "Blank Check",                  /* 0x08 */          \
  94.     "Vendor Unique",                /* 0x09 */          \
  95.     "Copy Aborted",                 /* 0x0a */          \
  96.     "Aborted Command",              /* 0x0b */          \
  97.     "Equal Error",                  /* 0x0c */          \
  98.     "Volume Overflow",              /* 0x0d */          \
  99.     "Miscompare Error",             /* 0x0e */          \
  100.     0,                              /* 0x0f */          \
  101.     "Scsi Bus Timeout",             /* 0x10 */          \
  102.     "File Mark",                    /* 0x11 */          \
  103.     "End of Tape",                  /* 0x12 */          \
  104.     "Length Error",                 /* 0x13 */          \
  105.     "Wrong Media Type",             /* 0x14 */          \
  106.     "Device Busy"}                  /* 0x15 */
  107. #endif  /* SK_NO_SENSE */
  108.  
  109. extern int  scsi_open(u_short, u_short, char *);
  110. extern long scsi_read(int, void *, long);
  111. extern long scsi_write(int, void *, long);
  112. extern long scsi_lseek(int, long, u_short);
  113. extern int  scsi_ioctl(int, u_short, long);
  114. extern int  scsi_close(int);
  115.  
  116. #endif  /* __sys_scsi_io_h */
  117.